<?php
namespace app\article\validate;
use think\Validate;
class LeaveMessage extends Validate {
    //验证字段
    protected $rule = [
        'id' => ['require','number'],
        'name' => ['require'],
        'address' => ['require'],
        'email' => ['require'],
        'phone_number' => ['require','number'],
        'leave_message' => ['require'],
        'create_time' => ['require'],
        'creater' => ['require'],
        'update_time' => ['require'],
        'updater' => ['require'],
        'status' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
        'name.require' => '姓名必须',
        'address.require' => '联系人地址必须',
        'email.require' => '邮箱必须',
        'phone_number.require' => '电话号码必须',
        'phone_number.number' => '电话号码不是数字',
        'leave_message.require' => '留言必须',
        'create_time.require' => '创建时间必须',
        'creater.require' => '创建者必须',
        'update_time.require' => '更新时间必须',
        'updater.require' => '更新者必须',
        'status.require' => '当前状态值必须',
        'status.number' => '当前状态值不是数字',
    ];

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','name','address','email','phone_number','leave_message','create_time','creater','update_time','updater','status']);
    }

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['name','address','email','phone_number','leave_message','create_time','creater','update_time','updater','status']);
    }
}
